<?php
/**
 * Created by PhpStorm.
 * User: qishengqiang
 * Date: 2022-06-05
 * Time: 16:52
 */

namespace app\models;


class Orders extends ModelBase
{
    protected $pk = 'orderId';

    public function getOrderStatusText()
    {
        switch ($this->orderStatus) {
            case 0:
                $text = '待支付';
                break;

            case -1:
                $text = '已撤销';
                break;

            case 1:
                $text = '已支付';
                break;

            case 2:
                $text = '已发货';
                break;

            case 3:
                $text = '已收货';
                break;
        }

        return $text;
    }

    public function express()
    {
        return $this->hasOne(OrderExpress::class, 'orderId', 'orderId');
    }

    public function orderGoods()
    {
        return $this->hasMany(OrderGoods::class, 'orderId', 'orderId');
    }

    public function user()
    {
        return $this->hasOne(Users::class, 'userId', 'userId');
    }
}